package java101;

import javax.swing.JOptionPane;

public class Triangularea {

	public static void main(String[] args) {
		
		String a;
		double aD;
		
		String b;
		double bD;
		
		String c;
		double cD;
		
		double s;
		double area;
		String answer;
		
		a = JOptionPane.showInputDialog("Enter a side of the triangle: ");
		aD = Double.parseDouble(a);
		
		b = JOptionPane.showInputDialog("Side A = " + a + "\nEnter another side: ");
		bD = Double.parseDouble(b);
		
		c = JOptionPane.showInputDialog("Side A = " + a + "\nSide B = " + b + "\nEnter the last side: ");
		cD = Double.parseDouble(c);
		
		s = .5 * (aD + bD + cD);
		area = Math.sqrt((s-aD)*(s-bD)*(s-cD));
		
		answer = String.format("Side A = %s\nSide B = %s\nSide C = %s\nThe area of the triangle is apprx.: %.4f", a, b, c, area);
		JOptionPane.showMessageDialog(null, answer, "Triangularea", JOptionPane.INFORMATION_MESSAGE);
	}

}
